#include "formsclass.h"
#include "ui_formsclass.h"
#include<QSqlQueryModel>
#include<QDebug>
#include"student.h"
#include<QSqlQuery>
#include<QSqlRecord>
#include<QDateTime>
#include"execsql.h"

FormSclass::FormSclass(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FormSclass)
{
    ui->setupUi(this);

}

FormSclass::~FormSclass()
{
    delete ui;
}
void FormSclass::showformSclassW()
{
    emit signalformSclass();
    this->show();
}

void FormSclass::showSW()
{
    Student *sw = new Student;
    sw->show();
    sw->selectBoxSlot(str);
    qDebug()<<m_xid;
}

 void FormSclass::slotSlogin()
 {
     sloginw->show();
     sloginw->str = str;

     sloginw->m_xid =ui->lineEdit_xid->text();
      sloginw->m_ScienceID =ui->lineEdit_science->text();
      sloginw->m_teacherId =ui->lineEdit_teacherid->text();
      sloginw->m_Classid=ui->lineEdit_classID->text();
      sloginw->m_RoomID = ui->lineEdit_roomid->text();
      sloginw->m_CheckinTime =ui->label_checkintime->text();
//     sloginw->m_xid = m_xid;
//     sloginw->m_teacherId = m_teacherId;
//     sloginw->m_RoomID = m_RoomID;
//     sloginw->m_Classid = m_Classid;
//     sloginw->m_CheckinTime = m_CheckinTime;
//     sloginw->m_ScienceID = m_ScienceID;
 }
void FormSclass::on_pb_checkin_cancle_clicked()
{
    this->close();
    this->showSW();
}

void FormSclass::on_pb_ok_clicked()
{
    sloginw = new SLogin;
    connect(sloginw,&SLogin::siignalslogin,this,&FormSclass::slotSlogin);
    this->hide();
    sloginw->showsloginW();
    ExecSQL e;
    m_xuehao = e.selectStudentInfo(str).getxuehao();
    m_xid =ui->lineEdit_xid->text();
    m_ScienceID =ui->lineEdit_science->text();
    m_teacherId =ui->lineEdit_teacherid->text();
    m_Classid=ui->lineEdit_classID->text();
    m_RoomID = ui->lineEdit_roomid->text();
    m_CheckinTime =ui->label_checkintime->text();
    cinfo=e.insertCheckinInfo(m_xid,m_ScienceID,m_teacherId ,m_Classid,m_RoomID,
                              m_CheckinTime,m_xuehao);
    cinfo.updateCheckinInfo(m_xid,m_ScienceID,m_teacherId ,m_Classid,m_RoomID,
                            m_CheckinTime,m_xuehao);
    cinfo.display();
}

void FormSclass::on_pb_time_clicked()
{
    m_xid =ui->lineEdit_xid->text();
    QDateTime time = QDateTime::currentDateTime();
     time_str = time.toString("yyyyMMddhh");
     ui->label_checkintime->setText(time_str);
}
